<?php

namespace App\Models\Admin;

use App\Models\Base;

class AdminRole extends Base
{

    /**
     * @var string $tableName 指定表名
     */
    protected $tableName = 'es_admin_role';

    /**
     * 编辑角色
     */
    public function edit(array $param)
    {
        $where = [];
        if ($id = $param['id'] ?? '') $where['id'] = $id;

        $data = [];
        if ($manuName = $param['role_name'] ?? '') $data['role_name'] = $manuName;
        if (isset($param['menu_ids'])) $data['menu_ids'] = $param['menu_ids'];

        if (!$where || !$data) return true;
        return self::create() -> where($where) -> update($data);
    }

    /**
     * 获取菜单id集合
     */
    public function menuIds($id)
    {
        return self::create() -> where(['id' => $id]) -> column('menu_ids');
    }

    /**
     * 获取菜单列表
     */
    public function menuList($menuIds)
    {
        
    }

}